package com.personal.service.Impl;

import com.github.pagehelper.PageHelper;
import com.personal.bo.NewResourcesBO;
import com.personal.mapper.DynamicMapper;
import com.personal.mapper.ResourcesMapper;
import com.personal.service.DynamicService;
import com.personal.utils.Result;
import com.personal.vo.ResourcesVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@Service
@Slf4j
public class DynamicServiceImpl implements DynamicService {

    @Autowired
    private DynamicMapper dynamicMapper;


    /**
     * 查询今日，本周，总的发布资源数量
     * @return
     */
    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public Result queryResourcesCount() {
        log.info("查询发布资源数量接口");
        HashMap<String, Integer> map = new HashMap<>();
        //查询今日发布资源数量
        int todayCount = dynamicMapper.getTodayResourcesCount();
        map.put("todayCount", todayCount);
        //查询本周内发布资源数量
        int weekCount = dynamicMapper.getWeekResourcesCount();
        map.put("weekCount",weekCount);
        //查询出总的资源发布数量
        int totalCount = dynamicMapper.getTotalCount();
        map.put("totalCount", totalCount);

        return Result.success(map);
    }
}
